/**
 * 
 */

package com.shy.base.vo;

import java.util.ArrayList;
import java.util.List;

import com.shy.base.util.StringUtils;

/**
 * <p>
 * Title:查询信息对象
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Company:ipebg
 * </p>
 * 
 * @author shy
 * @date 2016-8-24 上午11:16:41
 */
public class QueryParamVo {

    /** 查询语句 */
    private String whereHql;

    /** 参数列表 */
    private List<EntityTypeValue> params;

    /**
     * @return the whereHql
     */
    public String getWhereHql() {
        return whereHql;
    }

    /**
     * @param whereHql
     *            the whereHql to set
     */
    public void setWhereHql(String whereHql) {
        this.whereHql = whereHql;
    }

    /**
     * @return the params
     */
    public List<EntityTypeValue> getParams() {
        return params;
    }

    /**
     * @param params
     *            the params to set
     */
    public void setParams(List<EntityTypeValue> params) {
        this.params = params;
    }

    /**
     * 添加参数记录
     * 
     * @param paramName
     *            参数名
     * @param paramValue
     *            参数值
     * @author H2013788
     * @date 2017/11/22下午6:54:31
     */
    public void addParam(String paramName, Object paramValue) {
        if (this.params == null) {
            this.params = new ArrayList<EntityTypeValue>();
        }
        this.params.add(new EntityTypeValue(paramName, paramValue));
    }

    /**
     * 拼接條件語句
     * 
     * @param whereHql
     *            条件语句
     * @author H2013788
     * @date 2017/11/22下午6:54:54
     */
    public void addWhereHql(String whereHql) {
        //this.whereHql = this.whereHql == null ? " 1 = 1 " : this.whereHql;
    	this.whereHql = this.whereHql == null ? "" : this.whereHql;
    	if(StringUtils.isEmpty(this.whereHql) && whereHql.trim().toLowerCase().startsWith("and ")) {
    		whereHql = whereHql.replaceFirst("and", "");
    	}
        this.whereHql = this.whereHql + whereHql;
    }

}
